<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>测试页面</title>
    <script src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/3.6.0/jquery.min.js"></script>
    <script>
        // 获取课程信息的函数
        function fetchCourseById() {
            var courseId = document.getElementById("courseId").value;
            $.get("findById", {id: courseId}, function (data) {
                alert("查询成功!");
                document.getElementById("id").value = data?.id;
                document.getElementById("cname").value = data?.cname;
                document.getElementById("credit").value = data?.credit;
                document.getElementById("department").value = data?.department;
                document.getElementById("content").value = data?.content;
            });
        }

        // 更新课程信息的函数
        function updateCourse() {
            var courseData = {
                id: document.getElementById("id").value,
                cname: document.getElementById("cname").value,
                credit: document.getElementById("credit").value,
                department: document.getElementById("department").value,
                content: document.getElementById("content").value
            };
            $.post("updateById", courseData, function (response) {
                alert(response);
            });
        }
    </script>
</head>
<body>

<div>
    <!-- 获取课程信息的表单 -->
    <h2>查询课程</h2>
    <label for="courseId">输入课程id:</label>
    <input type="text" id="courseId" name="courseId">
    <button onclick="fetchCourseById()">查询课程</button>
    <br /><br />
    <!-- 更新课程信息的表单 -->
    <h2>更新课程信息：</h2>
    <label for="id">输入课程id:</label>
    <input type="text" id="id" name="id"><br><br>
    <label for="cname">课程名称:</label>
    <input type="text" id="cname" name="cname"><br><br>
    <label for="credit">学分:</label>
    <input type="text" id="credit" name="credit"><br><br>
    <label for="department">开设学院:</label>
    <input type="text" id="department" name="department"><br><br>
    <label for="content">内容:</label>
    <input type="text" id="content" name="content"><br><br>
    <button onclick="updateCourse()">更新课程</button>
</div>
</body>
</html>